package thread;

import java.util.Comparator;
import java.util.Timer;
import java.util.TimerTask;


//Timer(定时器)的使用
public class Demo20 {
    public static void main(String[] args) {
        Timer t1 = new Timer();
        t1.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("hello 2000");
            }
        },2000);

        Timer t2 = new Timer();
        t1.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("hello 3000");
            }
        },3000);

        Timer t3 = new Timer();
        t1.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("hello 1000");
            }
        },1000);


    }
}
